package info.hexin.json.parser;

import info.hexin.json.parser.parsing.ArrayParser;
import info.hexin.json.parser.parsing.MapParser;
import info.hexin.json.parser.parsing.StringParser;
import info.hexin.log.Log;
import info.hexin.log.Logs;

import java.util.HashMap;
import java.util.Map;

public class JsonParserConfig {
    private static Log log = Logs.get(); 
    private static final char MapStart = '{';
    private static final char MapEnd = '}';
    private static final char ListStart = '[';
    private static final char ListEnd = ']';
    private static final char MapPair = ':';
    private static final char SimpleString = 0;
    private static final char OtherString = 1;
    private static final char Comma = ',';
    private static final char String1 = '"';
    private static final char String2 = '\'';
    private static Map<Character, JsonParser> jsonRenderMap = new HashMap<Character, JsonParser>();
    static {
        jsonRenderMap.put(MapStart, MapParser.instance);
        jsonRenderMap.put(ListStart, ArrayParser.instance);
        jsonRenderMap.put(String1, StringParser.instance);
        jsonRenderMap.put(String2, StringParser.instance);
    }

    public static JsonParser getParser(Character character) {
        JsonParser jsonParser =  jsonRenderMap.get(character);
//        log.info("char1 >>>>"+ character +"  , jsonParser >>>> "+ jsonParser);
        return jsonParser;
    }
}
